]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Add optional keybindingMode parameter to pushModal()
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 10 Aug 2012 18:35:59 +0000 (20:35 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 17 Nov 2012 00:44:22 +0000 (01:44 +0100)
For now we just use it to assign an identifier to modal modes in
which we want to allow some keybindings, but we don't use it for
any actual filtering; we'll start doing this shortly.

https://bugzilla.gnome.org/show_bug.cgi?id=688202

js/gdm/loginDialog.js
js/ui/lookingGlass.js
js/ui/main.js
js/ui/messageTray.js
js/ui/modalDialog.js
js/ui/overview.js
js/ui/screenShield.js
js/ui/unlockDialog.js

index 911845281328ccd0749a09b3a740454db8d9bb7f..3db832e29b9cfaf1e30c7a8ae7c309c03caaeb2a 100644 (file)
@@ -660,6 +660,7 @@ const LoginDialog = new Lang.Class({
         this.parent({ shellReactive: true,
                       styleClass: 'login-dialog',
                       parentActor: parentActor,
+                      keybindingMode: Main.KeybindingMode.LOGIN_SCREEN,
                       shouldFadeIn: false });
         this.connect('destroy',
                      Lang.bind(this, this._onDestroy));
index 3c3d094af2fa732f91c2c76c4dad8e0b1c0b28c7..f5e47f47de5ac3e0c8bc8df11dad92884f1dc294 100644 (file)
@@ -1129,7 +1129,7 @@ const LookingGlass = new Lang.Class({
         if (this._open)
             return;
 
-        if (!Main.pushModal(this._entry))
+        if (!Main.pushModal(this._entry, { keybindingMode: Main.KeybindingMode.LOOKING_GLASS }))
             return;
 
         this._notebook.selectIndex(0);
index cc0587c79be4e34068de46da92ad1033f5620bc9..75ab45b2ec715fccf0c9bb9175f765941f1cadea 100644 (file)
@@ -40,6 +40,18 @@ const Util = imports.misc.util;
 const OVERRIDES_SCHEMA = 'org.gnome.shell.overrides';
 const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
 
+const KeybindingMode = {
+    NONE:          0,       // block all keybindings
+    NORMAL:        1 << 0,  // window mode
+    OVERVIEW:      1 << 1,
+    LOCK_SCREEN:   1 << 2,
+    UNLOCK_SCREEN: 1 << 3,
+    LOGIN_SCREEN:  1 << 4,
+    MESSAGE_TRAY:  1 << 5,
+    SYSTEM_MODAL:  1 << 6,
+    LOOKING_GLASS: 1 << 7
+};
+
 let componentManager = null;
 let panel = null;
 let overview = null;
@@ -56,6 +68,7 @@ let shellDBusService = null;
 let shellMountOpDBusService = null;
 let screenSaverDBus = null;
 let modalCount = 0;
+let keybindingMode = KeybindingMode.NORMAL;
 let modalActorFocusStack = [];
 let uiGroup = null;
 let magnifier = null;
@@ -498,11 +511,16 @@ function isInModalStack(actor) {
  *  - options: Meta.ModalOptions flags to indicate that the pointer is
  *             already grabbed
  *
+ *  - keybindingMode: used to set the current Main.KeybindingMode to filter
+ *                    global keybindings; the default of NONE will filter
+ *                    out all keybindings
+ *
  * Returns: true iff we successfully acquired a grab or already had one
  */
 function pushModal(actor, params) {
     params = Params.parse(params, { timestamp: global.get_current_time(),
-                                    options: 0 });
+                                    options: 0,
+                                    keybindingMode: KeybindingMode.NONE });
 
     if (modalCount == 0) {
         if (!global.begin_modal(params.timestamp, params.options)) {
@@ -532,8 +550,10 @@ function pushModal(actor, params) {
     modalActorFocusStack.push({ actor: actor,
                                 focus: curFocus,
                                 destroyId: actorDestroyId,
-                                focusDestroyId: curFocusDestroyId });
+                                focusDestroyId: curFocusDestroyId,
+                                keybindingMode: keybindingMode });
 
+    keybindingMode = params.keybindingMode;
     global.stage.set_key_focus(actor);
     return true;
 }
@@ -560,6 +580,7 @@ function popModal(actor, timestamp) {
         global.stage.set_key_focus(null);
         global.end_modal(timestamp);
         global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
+        keybindingMode = KeybindingMode.NORMAL;
 
         throw new Error('incorrect pop');
     }
@@ -572,6 +593,7 @@ function popModal(actor, timestamp) {
     if (focusIndex == modalActorFocusStack.length - 1) {
         if (record.focus)
             record.focus.disconnect(record.focusDestroyId);
+        keybindingMode = record.keybindingMode;
         global.stage.set_key_focus(record.focus);
     } else {
         let t = modalActorFocusStack[modalActorFocusStack.length - 1];
@@ -581,6 +603,7 @@ function popModal(actor, timestamp) {
         for (let i = modalActorFocusStack.length - 1; i > focusIndex; i--) {
             modalActorFocusStack[i].focus = modalActorFocusStack[i - 1].focus;
             modalActorFocusStack[i].focusDestroyId = modalActorFocusStack[i - 1].focusDestroyId;
+            modalActorFocusStack[i].keybindingMode = modalActorFocusStack[i - 1].keybindingMode;
         }
     }
     modalActorFocusStack.splice(focusIndex, 1);
@@ -591,6 +614,7 @@ function popModal(actor, timestamp) {
     global.end_modal(timestamp);
     global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
     Meta.enable_unredirect_for_screen(global.screen);
+    keybindingMode = KeybindingMode.NORMAL;
 }
 
 function createLookingGlass() {
index f1687d0f5accbc217df58d2edb057ea0dcafa66e..262ea15355edfa84b9ebf34467211fa8ccf85cfa 100644 (file)
@@ -1453,7 +1453,8 @@ const MessageTray = new Lang.Class({
 
         this.idleMonitor = new GnomeDesktop.IdleMonitor();
 
-        this._grabHelper = new GrabHelper.GrabHelper(this.actor);
+        this._grabHelper = new GrabHelper.GrabHelper(this.actor,
+                                                     { keybindingMode: Main.KeybindingMode.MESSAGE_TRAY });
         this._grabHelper.addActor(this._summaryBoxPointer.actor);
         this._grabHelper.addActor(this.actor);
         if (Main.panel.statusArea.activities)
index cb0a15f1bc4c8f4961961febe6aecbab471aa63c..04b0076729d18002083a828a16d70e22e6d41083 100644 (file)
@@ -37,10 +37,12 @@ const ModalDialog = new Lang.Class({
         params = Params.parse(params, { shellReactive: false,
                                         styleClass: null,
                                         parentActor: Main.uiGroup,
+                                        keybindingMode: Main.KeybindingMode.SYSTEM_MODAL,
                                         shouldFadeIn: true });
 
         this.state = State.CLOSED;
         this._hasModal = false;
+        this._keybindingMode = params.keybindingMode;
         this._shellReactive = params.shellReactive;
         this._shouldFadeIn = params.shouldFadeIn;
 
@@ -276,7 +278,8 @@ const ModalDialog = new Lang.Class({
     pushModal: function (timestamp) {
         if (this._hasModal)
             return true;
-        if (!Main.pushModal(this._group, { timestamp: timestamp }))
+        if (!Main.pushModal(this._group, { timestamp: timestamp,
+                                           keybindingMode: this._keybindingMode }))
             return false;
 
         this._hasModal = true;
index 658cb81a61b3795601581782a3d856fcb448d132..3f1663f335e18d42b7baaee2be71ceaae4d605d1 100644 (file)
@@ -591,7 +591,7 @@ const Overview = new Lang.Class({
         if (this._shown)
             return;
         // Do this manually instead of using _syncInputMode, to handle failure
-        if (!Main.pushModal(this._group))
+        if (!Main.pushModal(this._group, { keybindingMode: Main.KeybindingMode.OVERVIEW }))
             return;
         this._modal = true;
         this._animateVisible();
@@ -742,7 +742,8 @@ const Overview = new Lang.Class({
 
         if (this._shown) {
             if (!this._modal) {
-                if (Main.pushModal(this._group))
+                if (Main.pushModal(this._group,
+                                   { keybindingMode: Main.KeybindingMode.OVERVIEW }))
                     this._modal = true;
                 else
                     this.hide();
index 8de5c62455de875bc0adc046888440dca759b4e6..3338dcc0d8fbc6ae8fbfca0b11f1b5a228a8ed8d 100644 (file)
@@ -611,7 +611,7 @@ const ScreenShield = new Lang.Class({
         }
 
         if (!this._isModal) {
-            Main.pushModal(this.actor);
+            Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
             this._isModal = true;
         }
 
@@ -920,7 +920,7 @@ const ScreenShield = new Lang.Class({
 
     lock: function(animate) {
         if (!this._isModal) {
-            Main.pushModal(this.actor);
+            Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
             this._isModal = true;
         }
 
index 30699d9eb304069e96d8ad1f340866547be2539a..2f46d648e2b50579bd122996859423744aa472d4 100644 (file)
@@ -113,6 +113,7 @@ const UnlockDialog = new Lang.Class({
     _init: function(parentActor) {
         this.parent({ shellReactive: true,
                       styleClass: 'login-dialog',
+                      keybindingMode: Main.KeybindingMode.UNLOCK_SCREEN,
                       parentActor: parentActor
                     });